﻿using System;

namespace Anno.Util
{
    public class BashResult
	{
		/// <summary>
		/// 
		/// </summary>
		public string Output { get; private set; }

		/// <summary>
		/// 
		/// </summary>
		public string ErrorMsg { get; private set; }

		/// <summary>
		/// 
		/// </summary>
		public int ExitCode { get; private set; }

		/// <summary>
		/// 
		/// </summary>
		public int Id { get; private set; }

		/// <summary>
		/// 
		/// </summary>
		public string[] Lines
		{
			get
			{
				string output = this.Output;
				if (output == null)
				{
					return null;
				}
				return output.Split(Environment.NewLine.ToCharArray());
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="output"></param>
		/// <param name="errorMsg"></param>
		/// <param name="exitCode"></param>
		/// <param name="id"></param>
		internal BashResult(string output, string errorMsg, int exitCode, int id)
		{
			this.Output = ((output != null) ? output.TrimEnd(Environment.NewLine.ToCharArray()) : null);
			this.ErrorMsg = ((errorMsg != null) ? errorMsg.TrimEnd(Environment.NewLine.ToCharArray()) : null);
			this.ExitCode = exitCode;
			this.Id = id;
		}
	}
}
